package com.huaweicloud.servicestage.command;

import com.beust.jcommander.JCommander;

public class Command {

    public static JCommander initCommand(String[] args) {
        CommandInit init = new CommandInit();
        CommandUgrade upgrade = new CommandUgrade();
        CommandList list = new CommandList();
        JCommander jc = JCommander.newBuilder()
            .addCommand(CommandAction.INIT, init)
            .addCommand(CommandAction.UPGRADE, upgrade)
            .addCommand(CommandAction.LIST, list)
            .build();
        try {
            jc.parse(args);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            jc.usage();
            System.exit(1);
        }
        return jc;
    }
}
